package com.youlai.boot.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.youlai.boot.common.result.PageResult;
import com.youlai.boot.common.result.Result;
import com.youlai.boot.system.model.form.WxKfRecordForm;
import com.youlai.boot.system.model.query.WxKfRecordPageQuery;
import com.youlai.boot.system.model.vo.WxKfRecordPageVO;
import com.youlai.boot.system.service.WxKfRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * 护理记录表 前端控制器
 *
 * @author Ray Hao
 * @since 2025-09-01
 */
@Tag(name = "护理记录表接口")
@RestController
@RequestMapping("/api/v1/wxKfRecords")
@RequiredArgsConstructor
public class WxKfRecordController {

    private final WxKfRecordService wxKfRecordService;

    @Operation(summary = "护理记录表分页列表")
    @GetMapping("/page")
    public PageResult<WxKfRecordPageVO> listPagedWxKfRecords(WxKfRecordPageQuery queryParams) {
        IPage<WxKfRecordPageVO> result = wxKfRecordService.listPagedWxKfRecords(queryParams);
        return PageResult.success(result);
    }

    @Operation(summary = "新增护理记录表")
    @PostMapping
    public Result saveWxKfRecord(@RequestBody @Valid WxKfRecordForm formData) {
        boolean result = wxKfRecordService.saveWxKfRecord(formData);
        return Result.judge(result);
    }

    @Operation(summary = "护理记录表表单数据")
    @GetMapping("/{id}/form")
    public Result<WxKfRecordForm> getWxKfRecordForm(
            @Parameter(description = "护理记录表ID") @PathVariable Long id
    ) {
        WxKfRecordForm formData = wxKfRecordService.getWxKfRecordFormData(id);
        return Result.success(formData);
    }

    @Operation(summary = "修改护理记录表")
    @PutMapping(value = "/{id}")
    public Result updateWxKfRecord(@Parameter(description = "护理记录表ID") @PathVariable Long id,
                                   @RequestBody @Validated WxKfRecordForm formData) {
        boolean result = wxKfRecordService.updateWxKfRecord(id, formData);
        return Result.judge(result);
    }

    @Operation(summary = "删除护理记录表")
    @DeleteMapping("/{ids}")
    public Result deleteWxKfRecords(
            @Parameter(description = "护理记录表ID，多个以英文逗号(,)分割") @PathVariable String ids
    ) {
        boolean result = wxKfRecordService.deleteWxKfRecords(ids);
        return Result.judge(result);
    }
}
